package come.bjpowernode.javase.io.imageio;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.net.URL;

public class ReadURL {
    public static void main(String[] args) {
        Image image = null;
        try {
            URL url = new URL("https://image.baidu.com/search/detail?ct=503316480&z=undefined&tn=baiduimagedetail&ipn=d&word=%E5%9B%BE%E7%89%87&step_word=&ie=utf-8&in=&cl=2&lm=-1&st=undefined&hd=undefined&latest=undefined&copyright=undefined&cs=3212920999,1827079299&os=636890994,400800611&simid=3421856417,249752931&pn=0&rn=1&di=64240&ln=1723&fr=&fmq=1629945429997_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&is=0,0&istype=0&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=0&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%253A%252F%252Fpic27.nipic.com%252F20130123%252F11872424_205643476146_2.jpg%26refer%3Dhttp%253A%252F%252Fpic27.nipic.com%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1632537427%26t%3D810d95d308c7026c1bd3b8dd6ea1418f&rpstart=0&rpnum=0&adpicid=0&nojc=undefined");
            image = ImageIO.read(url);
        } catch (IOException e) {
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setSize(300, 300);
        JLabel label = new JLabel(new ImageIcon(image));
        frame.add(label);
        frame.setVisible(true);
    }
}
